﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using NovinMedia.Data;

namespace asscope.Data.Layer
{
    [DataObject(true)]
    public class Country
    {       
        [DataObjectMethod(DataObjectMethodType.Fill)]
        public DataSet SelectAll()
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
 
                };
            return dbo.RunProcedure("sp_country_SelectAll", parameters, "country");
        }

        [DataObjectMethod(DataObjectMethodType.Fill)]
        public DataSet SelectRow(string id, string code)
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
					new SqlParameter("id",id),
					new SqlParameter("code",code) 
                };
            return dbo.RunProcedure("sp_country_SelectRow", parameters, "country");
        }

        [DataObjectMethod(DataObjectMethodType.Insert)]
        public int InsertRow(string id, string code, string name)
        {
            int RowsAffected = 0;
            int Result = 0;
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("id",new System.Data.SqlTypes.SqlGuid(id)),
					new SqlParameter("code",code),
					new SqlParameter("name",name) 
				};
            Result = dbo.RunProcedure("sp_country_Insert", parameters, out RowsAffected);
            return Result;
        }

        [DataObjectMethod(DataObjectMethodType.Update)]
        public int UpdateRow(string id, string code, string name)
        {
            int RowsAffected = 0;
            int Result = 0;
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("id",id),
					new SqlParameter("code",code),
					new SqlParameter("name",name) 
				};
            Result = dbo.RunProcedure("sp_country_Update", parameters, out RowsAffected);
            return Result;
        }

        [DataObjectMethod(DataObjectMethodType.Delete)]
        public int DeleteRow(string id, string code)
        {
            int RowsAffected = 0;
            int Result = 0;
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("id",id),
					new SqlParameter("code",code) 
				};
            Result = dbo.RunProcedure("sp_country_DeleteRow", parameters, out RowsAffected);
            return Result;
        }
    }
}